package com.peace.hospital.mapper.drugstorage;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.peace.hospital.entity.drugstorage.Outwarehouse;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;


/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xie
 * @since 2019-11-25
 */
@Mapper
public interface OutwarehouseMapper extends BaseMapper<Outwarehouse> {
//    添加入库单信息
    @Insert("insert into drugstorage.outwarehouse(staid,outdate) values(#{staid},#{outdate})")
    public int addOutwa(Outwarehouse outwarehouse);
//查询入库最后一条入库单id
    @Select("select outid from drugstorage.outwarehouse order by outid desc limit 1")
    public Outwarehouse findLastOutwa();
//    查询入库单信息
    @Select("<script>\n"+
            "select outid,outdate,staid\n"+
            "from drugstorage.outwarehouse\n"+
            "<where>"+
            "<if test='outid != null'>and outid = #{outid}</if>"+
            "<if test='staid != null'>and staid = #{staid}</if>"+
            "</where>"+
            "</script>")
    @Results({
             @Result(column="staid",property="staffinfo",one=@One(select="com.peace.hospital.mapper.publicn.StaffinfoMapper.findById",fetchType= FetchType.LAZY))
    })
    public List<Outwarehouse> findOutwa(Outwarehouse outwarehouse);
}
